<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
    <form class="layui-form serch" action="{:url('admin/member/index')}" method="post">
        <div class="layui-form-item" style="float: left;">
            <div class="layui-input-inline">
                <input type="text" name="keywords" lay-verify="title" value="{$Request.param.keywords}" autocomplete="off" placeholder="请输入成员姓名" class="layui-input layui-btn-sm">
            </div>
            <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">立即提交</button>
            <a class="layui-btn layui-btn-primary" href="{:url('admin/member/index')}" class="a_menu">
                重置
            </a>
            <a class="layui-btn layui-btn-sm a_menu" href="{:url('admin/member/publish')}" class="a_menu">
                添加新成员
            </a>
        </div>
    </form>
</fieldset>
<table class="layui-table" lay-even="" lay-skin="row" lay-size="sm">
    <colgroup>
        <col width="50">
        <col width="100">
        <col width="150">
        <col width="150">
        <col width="150">
        <col width="300">
        <col width="60">
    </colgroup>
    <thead>
    <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>图片</th>
        <th>手机号</th>
        <th>城乡</th>
        <th>简介</th>
        <th>创建时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="member" id="vo"}
    <tr>
        <td>{$key+1}</td>
        <td>{$vo.mname}</td>
        <td>{$vo.msex==1?'男':'女'}</td>
        <td>
            {empty name="$vo.image"}
                暂无数据
            {else/}
                <a href="{$vo.image|geturl}" class="tooltip"><img src="{$vo.image|geturl}" width="20" height="20"></a>
            {/empty}
        </td>
        <td>{$vo.phone}</td>
        <td>{$vo.address}</td>
        <td>{$vo.content}</td>
        <td>{$vo.create_time|date='Y/m/d H:i:s',###}</td>
        <td class="operation-menu">
            <a href="{:url('admin/member/publish',['mid'=>$vo.mid])}" class="layui-btn layui-btn-xs a_menu" style="margin-right: 0;font-size:12px;">修改</a>
            <a class="layui-btn layui-btn-xs layui-btn-danger delete" mid="{$vo.mid}" style="margin-right: 0;font-size:12px;">删除</a>
        </td>
    </tr>
    {/volist}
    </tbody>
</table>
<div style="margin: 0 auto;width:600px">{$page}</div>

<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script>
    var message;
    layui.config({
        base: '__JS__/',
        version: '1.0.1'
    }).use(['app', 'message'], function() {
        var app = layui.app,
            $ = layui.jquery,
            layer = layui.layer;
        //将message设置为全局以便子页面调用
        message = layui.message;
        //主入口
        app.set({
            type: 'iframe'
        }).init();
    });
</script>
<script type="text/javascript">
        $(function(){
            var x = 10;
            var y = 20;
            $(".tooltip").mouseover(function(e){
                var tooltip = "<div id='tooltip'><img src='"+ this.href +"' alt='产品预览图' height='200'/>"+"<\/div>"; //创建 div 元素
                $("body").append(tooltip);  //把它追加到文档中
                $("#tooltip")
                    .css({
                        "top": (e.pageY+y) + "px",
                        "left":  (e.pageX+x)  + "px"
                    }).show("fast");    //设置x坐标和y坐标，并且显示
            }).mouseout(function(){
                $("#tooltip").remove();  //移除
            }).mousemove(function(e){
                $("#tooltip")
                    .css({
                        "top": (e.pageY+y) + "px",
                        "left":  (e.pageX+x)  + "px"
                    });
            });
        })



    $('.delete').click(function(){
        var mid = $(this).attr('mid');
        layer.confirm('确定要删除?', function(index) {
            $.ajax({
                type:'post',
                url:"{:url('admin/member/delete')}",
                data:{mid:mid},
                success:function(res) {
                    layer.msg(res.msg);
                    if(res.code == 1) {
                        setTimeout(function(){
                            location.href = res.url;
                        },1500)
                    }
                }
            })
        })
    })
</script>
<script type="text/javascript">
    layui.use('layer', function(){
        var layer = layui.layer;
        $('.a_menu').click(function(){
            var url = $(this).attr('href');
            var a = 0;
            $.ajax({
                url:url
                ,async:false
                ,success:function(res){
                    if(res.code == 0) {
                        layer.msg(res.msg);
                        a = 1;
                    }
                }
            })
            if(a === 0) {
                layer.open({
                    type:2,
                    content:url,
                    area: ['700px', '600px'],
                    end:function(){
                        location.reload();
                    }
                });
            }
            return false;
        })

        $('.preview').click(function(){
            var url = $(this).attr('href');
            layer.open({
                type:2,
                content:url,
                area: ['550px', '400px']
            });
            return false;
        })
    });
</script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //常规用法
        laydate.render({
            elem: '#create_time'
        });
    });
</script>
</body>
</html>
